//
//  ReloadButton.m
//  Toyohu
//
//  Created by Heige on 16/4/14.
//  Copyright © 2016年 celia. All rights reserved.
//

#import "ReloadButton.h"
#import "ReloadButtonModel.h"
#import <Masonry/Masonry.h>

@interface ReloadButton()

@property (nonatomic,weak) UIImageView *iconImageView;
@property (nonatomic,weak) UILabel *nameLabel;

@end

@implementation ReloadButton

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        UIImageView *iconImageView = [[UIImageView alloc] init];
        self.iconImageView = iconImageView;
        [self addSubview:iconImageView];
            
        UILabel *nameLabel = [[UILabel alloc] init];
        nameLabel.textAlignment = NSTextAlignmentCenter;
        nameLabel.font = [UIFont systemFontOfSize:13];
        nameLabel.textColor = [UIColor colorWithRed:66/255.0 green:201/255.0 blue:242/255.0 alpha:1];
        self.nameLabel = nameLabel;
        [self addSubview:nameLabel];
        
        [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.centerY.equalTo(self);
            make.width.height.equalTo(@13);
            
        }];
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.centerY.equalTo(self);
            make.height.equalTo(@40);
            make.left.equalTo(self.iconImageView);
        }];
        
        
    }
    return self;
}


- (void)setModel:(ReloadButtonModel *)model
{
    _model = model;
    
    self.iconImageView.image = [UIImage imageNamed:model.icon];
    self.nameLabel.text = model.name;
    
}





@end
